#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd ${DIR}

namespace=lrc32
artifactId=phoronix-test-suite
version=10.8.4


# hub.docker.com/szopen
group=swr.cn-east-3.myhuaweicloud.com/intetech

# docker

# docker buildx imagetools inspect lrc32/xde-temurin:11-jdk-focal-cn
docker pull --platform=linux/amd64 ${namespace}/${artifactId}:${version}
docker tag ${namespace}/${artifactId}:${version} ${group}/${artifactId}:${version}-amd64
docker push ${group}/${artifactId}:${version}-amd64
docker rmi ${namespace}/${artifactId}:${version}

docker pull --platform=linux/arm64 ${namespace}/${artifactId}:${version}
docker tag ${namespace}/${artifactId}:${version} ${group}/${artifactId}:${version}-arm64
docker push ${group}/${artifactId}:${version}-arm64
docker rmi ${namespace}/${artifactId}:${version}

# push version manifest
docker manifest rm ${group}/${artifactId}:${version}
docker manifest create  --amend ${group}/${artifactId}:${version} \
${group}/${artifactId}:${version}-amd64 \
${group}/${artifactId}:${version}-arm64

docker manifest push ${group}/${artifactId}:${version}

# push latest manifest
docker manifest rm ${group}/${artifactId}:latest
docker manifest create --amend ${group}/${artifactId}:latest \
 ${group}/${artifactId}:${version}-amd64 \
 ${group}/${artifactId}:${version}-arm64
docker manifest push ${group}/${artifactId}:latest


rm -rf ${artifactId}-amd64.tar
rm -rf ${artifactId}-arm64.tar